﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Xna.Framework;



namespace FXnaEngine
{

    /// <summary>
    /// 基础控件组
    /// </summary>
   public abstract class FComponent
    {


       /// <summary>
        /// Entity this component belongs to.
        /// </summary>
       protected FEntity parentEntity;

        public FEntity ParentEntity
        {
            get { return parentEntity; }
            
        }

       

        /// <summary>
        /// Whether or not this component is active. When active this component will have Update()
        /// called on it each frame.
        /// </summary>
        public bool Active
        {
            get { return active; }
        }
        private bool active;

        /// <summary>
        /// Create a component
        /// </summary>
        /// <param name="parent">Entity this component belongs to.</param>
        public FComponent(FEntity parent)
        {
            this.parentEntity = parent;

            Initialize();
        }

        /// <summary>
        /// Initialize the component, which will attach it to the entity
        /// </summary>
        public virtual void Initialize()
        {
            this.parentEntity.AddComponent(this);
        }

        /// <summary>
        /// Shutdown the component and remove it from the entity and scene (if needed)
        /// </summary>
        public virtual void Shutdown() { }




        /// <summary>
        /// Send a message directly to components through this method.
        /// </summary>
        /// <param name="message">Message to send</param>
        /// <returns>Returns true if message was handled</returns>
        public abstract bool ExecuteMessage(IMessage message);

        /// <summary>
        /// Loads all needed ContentManager content.
        /// </summary>
        public virtual void LoadContent() { }

        /// <summary>
        /// Unloads all ContentManager content.
        /// </summary>
        public virtual void UnloadContent() { }

        /// <summary>
        /// Update the component
        /// </summary>
        /// <param name="gameTime">XNA Timing snapshot</param>
        public virtual void Update(GameTime gameTime) { }

        /// <summary>
        /// Update the component, at a fixed rate in sync with the physics world
        /// </summary>
        /// <param name="gameTime">XNA Timing snapshot</param>
        public virtual void FixedUpdate(GameTime gameTime) { }

     



      

     

    }
}
